const conn = require('../app/databse')
class userService {
  async insert(user) {
    // 插入数据库
    const statement = 'INSERT INTO user (name,password) VALUES (?,?)'
    await conn.execute(statement, [user.name, user.password])
  }
  async findByName(name) {
    const statement = 'SELECT * from `user` WHERE name = ?'
    const result = await conn.execute(statement, [name])
    return result[0]
  }
}

module.exports = new userService()